package com.mdxq.mall.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig2 {
    public static final String EXCHANGE_NAME = "upbm_exchange";//交换机的名字
    public static final String QUEUE_NAME = "upbm_queue";

    @Bean("normalQueue1")
    public Queue queue(){
        return QueueBuilder.durable(QUEUE_NAME)//是否持久话
                .expires(1000*60*60*24)//队列连续24小时未使用，就销毁
                .ttl(60*1000)
                .build();
    }
    @Bean("normalExchange1")
    public Exchange exchange(){
        //创建一个能持久化消息的主题交换机
        return ExchangeBuilder.topicExchange(EXCHANGE_NAME).durable(true).build();
    }
    @Bean("binding1")
    public Binding binding(@Qualifier("normalExchange1") Exchange exchange,@Qualifier("normalQueue1")Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with("person.*").noargs();
    }
}
